package ncku.account.event.old;
import java.util.Scanner;
import ncku.account.data.GlobalData;

public class DeleteTransaction {
	Scanner scanner = new Scanner(System.in);
	
	int chooseIndex=0;  //選擇修改之Transaction index
	int range = GlobalData.getTransactionNumber();  //取得Transaction總數
	
	public DeleteTransaction() throws Exception{
		chooseIndex = ChooseTransaction();
		GlobalData.delete(chooseIndex);
	}
    
    public int ChooseTransaction(){
    	int input;  //輸入的暫存器
    	listTransaction show = new listTransaction();
    	show.listTransaction();  //輸出所有Transaction
    	
    	while(true){
    		System.out.println("請輸入對應Transaction序號:");
    		input = Integer.valueOf(scanner.next());
    		
    		if((input>0) && (input<=range)){  //若輸入之index值符合範圍內(0~range)，即跳出此迴圈；若否則請使用者繼續輸入
    			return (input-1);
    		}
    		else{
    			System.out.println("輸入之序號錯誤!");
    		}
    	}
    }
}